/*
 * Directory.h
 *
 *  Created on: Apr 19, 2011
 *      Author: 
 */

#ifndef DIRECTORY_H_
#define DIRECTORY_H_

#include <vector>
#include <list>
#include "Datafile.h"

namespace dir {
	
	struct directoryEntry {
	private:
		ino_x inodeNr;
		string fileName;
	public:
		directoryEntry(ino_x nr, char* name){
			inodeNr = nr;
			fileName = name;
			//cout << "new Entry: " << inodeNr << ": " << fileName << endl;
		};
		ino_x getNr(){ return inodeNr; };
		char* getName(){ /*cout << "my name: " << fileName << endl;*/ return (char*)fileName.c_str(); };
	};
}

using namespace dir;

class Directory : public Datafile {
private:
	vector<directoryEntry*>* entryList;
	
public:
	static bool compareFilenames(char*, char*);
	Directory(Inode*);
	virtual ~Directory();
	bool addFilename(char*, ino_x);
	void deleteFilename(char*);
	list<string>* getFilenames();
	ino_x getInodeNumber(char*);
	ino_x getInodeNumber();
	void parseDirectory();
	void print();
	//void printDetail();
	const char* formulateName(byte*, int);
	ino_x formulateNumber(byte*);
	void write(directoryEntry*);
	bool addNewFile(char*, ino_x);
};

#endif /* DIRECTORY_H_ */
